<?php
class Register extends CI_Controller {
	public function index() {
		
		print_r($HTTP_POST_VARS);
		
		$var = $this->form_validation;
		
		$var->set_rules ( 'fname', 'lang:fname', 'trim|required|max_length[100]' );
		$var->set_rules ( 'lname', 'lang:lname', 'trim|required|max_length[100]' );
		$var->set_rules ( 'email', 'lang:email', 'trim|required|valid_email|is_unique[address.email]' );
		$var->set_rules ( 'address', 'lang:address', 'trim|required|max_length[300]' );
		$var->set_rules ( 'country', 'lang:country', 'trim|min_length[1]|max_length[100]' );
		$var->set_rules ( 'state', 'lang:state', 'trim|required|max_length[100]' );
		$var->set_rules ( 'username', 'lang:username', 'trim|required' );
		$var->set_rules ( 'password', 'lang:password', 'trim|required|min_length[4]|max_length[100]|matches[cpassword]' );
		$var->set_rules ( 'cpassword', 'lang:cpassword', 'trim|required' );
		
				
		if ($var->run () == FALSE) {
			$this->template->write_view ( 'left', 'front_end/layout/left', null, TRUE );
			$this->template->write_view ( 'center', 'front_end/register/index', null, TRUE );
			$this->template->write_view ( 'menu', 'front_end/layout/menu', null, TRUE );
			$this->template->write_view('menu_footer','front_end/layout/menu_footer',null,TRUE);
			$this->template->load ();
		
		} else {
		 	$this->User_model->register ();
		 	redirect('home');
		}
			
	}
	public function regis_user() {
		/*$fname = $_GET['fname'];
		$email = $_GET['email'];
		$address = $_GET['address'];
		$phone = $_GET['phone'];
		$city = $_GET['city'];
		$status = $_GET['status'];
		$lname = $_GET['lname'];
		$username = $_GET['username'];*/
		/*$password = $_GET ['password'];
		$cpassword = $_GET ['cpassword'];
		print_r ( $password );
		print_r ( $cpassword );*/
		/*if($password == $cpassword)
		{
		echo $this->User_model->register ();
		}
		else {
		 echo 'loi';
		}*/
	
	/*$this->form_validation->set_rules ( 'password', 'pass', 'trim|required|min_length[4]|max_length[12]|matches[cpassword]' );
		$this->form_validation->set_rules ( 'cpassword', 'passf', 'trim|required|min_length[4]|max_length[12]' );*/
	/*$this->form_validation->set_rules ( 'password', 'aa', 'trim|required|min_length[4]|max_length[12]|is_unique[users.username]' );*/
	
	}

}
